import { http } from "@/utils/http";

export const useHistoryAPI = () => {
  // 添加播放记录
  const addPlayHistory = (userId: string, musicId: string): any => {
    return http.post(`/user/playRecord/add`, {
      userId,
      musicId,
    });
  };

  // 获取播放记录数量
  const getPlayHistoryCount = (userId?: string): any => {
    return http.get(`/user/playRecord/count?userId=${userId}`);
  };

  // 分页查询历史记录详细信息
  const getPlayHistoryPage = (
    userId?: string,
    page: number = 1,
    rows: number = 15
  ): any => {
    return http.get(`/user/playRecord/details/page`, {
      params: {
        userId,
        page,
        rows,
      },
    });
  };

  return {
    addPlayHistory,
    getPlayHistoryCount,
    getPlayHistoryPage,
  };
};
